Export And Commit Table Schemas
π <ENV> - [BigQuery] Export and Commit Table Schemasβ
This GitHub Actions workflow automates the extraction of BigQuery table schemas from the bqDataLake dataset and commits them to the repository. It helps ensure that your schema definitions remain version-controlled and in sync with BigQuery.
π Workflow Triggerβ
This workflow is triggered manually via the GitHub actions in function repo.
π Environment Variablesβ
| Variable | Description |
|---|---|
GCP_PROJECT_ID | GCP Project ID (e.g., biddirect-2) |
DATASET_ID | BigQuery dataset ID (e.g., bqDataLake) |
π§±οΈ Workflow Job: export-and-commit-bigquery-schemasβ
| Step | Description |
|---|---|
| Checkout repository | Clones the GitHub repository to the runner. |
| Authenticate with GCP | Authenticates using a service account (<ENV>_BIGQUERY_ADMIN_SERVICE_ACCOUNT) stored in GitHub Secrets. |
| Set up Cloud SDK | Installs and configures the Google Cloud SDK CLI. |
| Create output directory | Creates the directory to store schema JSON files. |
| Get all schemas from BigQuery | Iterates over all tables in the dataset (excluding _changelog and non-table types), exports schema definitions, and saves them to local files. |
| Commit and Push Schema Files | Stages and commits any updated schema files to the repository. |
π§Ή Export Logic Summaryβ
-
Skips tables ending with
_changelog -
Skips views or other non-
TABLEresources -
Removes
_latestsuffix from table names when naming schema files -
Stores output in:
functions/src/bqDataLake/definitions/tableSchemas/
Example:
Table: accounts_latest β File: accounts.json
π Required Secretsβ
| Secret Name | Description |
|---|---|
<ENV>_BIGQUERY_ADMIN_SERVICE_ACCOUNT | Service account key JSON for GCP auth. |
β Example Usageβ
To run this workflow:
- Go to the Actions tab in your GitHub repository.
- Select the workflow
<ENV> - [BigQuery] Export and Commit Table Schemas. - Click "Run workflow".
This will:
- Export schemas for all physical
_latesttables in thebqDataLakedataset - Save each schema in JSON format to the repo
- Automatically commit and push the updated files to the branch from which the workflow was executed
This workflow ensures that schema changes are tracked alongside application code.